{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.5 64-bit ('base': conda)",
   "metadata": {
    "interpreter": {
     "hash": "aa9e82663741a35949d10b71616b7da32b0b1a8a92bded1e278bf973221dadc2"
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow.keras import layers, Sequential"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = tf.random.normal([2, 80, 100])\n",
    "xt = x[:, 0, :]\n",
    "cell = layers.LSTMCell(64)\n",
    "\n",
    "state = [tf.zeros([2, 64]), tf.zeros([2, 64])]\n",
    "out, state = cell(xt, state)\n",
    "\n",
    "for xt in tf.unstack(x, axis=1):\n",
    "    out, state = cell(xt, state)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "31188655e-01, -1.94162160e-01, -3.06775212e-01,\n",
       "          1.01462042e+00, -9.92354080e-02,  5.34758627e-01,\n",
       "          9.44119453e-01,  1.04872108e-01, -9.72182691e-01,\n",
       "          5.65628469e-01,  4.27105397e-01, -3.89256805e-01,\n",
       "          8.30005407e-02,  6.42286003e-01,  7.54117072e-01,\n",
       "          3.13607365e-01, -2.43205845e-01,  3.58062267e-01,\n",
       "          9.24447238e-01]], dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[-1.0082681 , -0.7169838 , -0.64191556, -1.6131672 ,  1.885752  ,\n",
       "          0.10308741,  0.48548254,  1.0225661 , -0.3014842 ,  0.7072958 ,\n",
       "         -0.2633699 ,  0.5970585 ,  1.0375458 ,  0.7774142 , -0.46519944,\n",
       "          0.758421  , -0.40312812,  1.6172273 , -0.17997071,  0.45205772,\n",
       "         -0.39933014, -0.8891409 , -1.0633    ,  1.0866635 ,  0.32001987,\n",
       "          2.1060617 ,  0.9163298 , -1.5839272 ,  0.00440305,  0.57198983,\n",
       "         -0.3908195 ,  2.0614455 ,  0.05949374, -0.8229683 ,  0.24717976,\n",
       "          0.09208333,  0.06665916,  0.8937841 ,  0.06615426,  0.52476865,\n",
       "         -0.93979144,  0.16051494, -0.38060316,  0.01611448, -0.5837646 ,\n",
       "         -0.69045717, -0.3608919 ,  0.01520735, -0.71140534,  0.6873449 ,\n",
       "          1.0453687 , -0.5313164 ,  1.6375325 ,  0.03819385,  0.7752644 ,\n",
       "         -0.61416274, -0.8744075 , -2.849351  ,  0.5133212 ,  0.6789571 ,\n",
       "          0.79394865, -0.10033941, -0.95887923,  0.26833397,  0.5451434 ,\n",
       "          1.42466   ,  2.3867857 , -1.0200753 ,  2.7814775 , -0.86436146,\n",
       "          0.27484515, -0.41016254, -0.46007916, -0.7629825 , -0.37405434,\n",
       "          0.1222683 , -1.3854425 ,  0.41900268, -0.776455  ,  0.8317982 ,\n",
       "          0.5676773 ,  0.08662071, -0.47264752,  0.20616162,  0.87766576,\n",
       "          1.0857376 ,  0.14553975,  1.7833344 ,  1.0547271 , -0.36035407,\n",
       "         -0.63148165,  0.30651972, -0.5662722 ,  1.4138483 , -0.40737405,\n",
       "          0.6142177 , -0.8046152 , -0.32913998, -0.147935  ,  0.40756246],\n",
       "        [-0.8232054 , -0.8677997 , -0.36508736, -3.0806646 ,  0.2867548 ,\n",
       "          0.3250964 , -0.22941269, -0.07225867,  1.0539043 , -0.7424676 ,\n",
       "          0.6352537 ,  0.9924946 , -0.53686243,  1.0278388 ,  1.8754898 ,\n",
       "          1.3315588 ,  0.39667174, -0.47007346,  0.11445648, -1.2560569 ,\n",
       "         -0.1317871 ,  0.2947652 ,  0.6388418 , -2.340515  ,  0.2549186 ,\n",
       "          0.978103  ,  0.3055608 , -0.06146536, -0.3772804 , -0.7783768 ,\n",
       "          0.41722   ,  0.8496746 ,  0.02238918,  0.38316292, -2.3736496 ,\n",
       "          0.580347  , -0.06736881, -0.26581448, -0.73462796, -0.03835633,\n",
       "         -0.612038  ,  0.8727158 ,  0.6767647 , -1.2167169 , -1.2957367 ,\n",
       "          1.1056528 , -0.06814725,  1.6076337 , -1.738795  ,  0.796661  ,\n",
       "          1.3372166 , -0.28883377,  0.7059287 ,  0.767154  ,  0.07817661,\n",
       "          0.3601581 , -0.986927  ,  1.3256298 , -0.93709   ,  0.82049215,\n",
       "         -0.50960743,  0.8444108 , -0.03262995,  1.2751954 ,  0.7734421 ,\n",
       "          1.1812483 , -1.3361517 ,  0.64546597, -1.1153456 ,  0.16442302,\n",
       "          0.9110888 ,  0.02313077, -0.5345613 , -0.49913996,  1.0996169 ,\n",
       "          1.4556094 ,  0.35596958, -1.2931032 , -1.3201237 , -0.8063104 ,\n",
       "         -0.33011293, -2.2940712 ,  0.2878352 , -0.6670297 , -0.3385692 ,\n",
       "         -0.79809254,  1.7945113 ,  0.30667582, -0.1166999 ,  0.20085907,\n",
       "         -0.8288257 ,  0.07246944, -0.99769384, -0.5848211 , -1.4991639 ,\n",
       "         -0.23824312,  0.36863658,  0.448405  , -0.6600465 , -0.8716988 ]],\n",
       "       dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[-1.442713  ,  0.25006735, -0.39933068,  0.20419244, -2.0836067 ,\n",
       "         -0.7044544 ,  0.75537246,  0.5100944 ,  1.4219061 , -0.5157692 ,\n",
       "          0.56134844, -0.66901493, -1.765456  ,  0.45172763,  0.7625639 ,\n",
       "         -1.027767  ,  0.73745126, -0.05134686,  0.13047066,  0.33002406,\n",
       "          1.5848165 , -0.11044451,  0.6100068 ,  0.76483905, -1.3670607 ,\n",
       "          1.1090717 , -0.75117445,  1.3414025 ,  0.29168326, -0.689312  ,\n",
       "         -0.06961619, -2.926905  ,  0.8387827 , -0.1585703 ,  0.06262799,\n",
       "         -1.2403574 , -0.62107533,  0.33906662, -0.6725963 , -0.7508709 ,\n",
       "          0.40394086, -0.810274  , -0.01703784,  0.32698983,  0.1492953 ,\n",
       "         -1.130182  ,  0.72406024,  0.3563005 , -1.9058679 ,  0.90116006,\n",
       "         -1.0330874 , -1.0606649 ,  1.1590608 , -0.20412669,  0.14012207,\n",
       "         -0.7282677 ,  0.04555842,  0.46955985,  1.4679039 ,  1.1649493 ,\n",
       "          0.1773796 , -1.4786985 ,  1.2474174 , -1.087365  ,  1.5736668 ,\n",
       "          1.7179649 , -0.50750625, -0.62715566,  1.5172364 , -0.883713  ,\n",
       "         -2.0737565 , -0.69147205, -0.45028907, -0.05645877, -0.8212604 ,\n",
       "          0.29122025,  0.18694785,  1.1925268 ,  2.2855682 , -0.65284437,\n",
       "          0.02975491,  2.2566118 ,  0.47152436, -1.9238734 ,  0.7163149 ,\n",
       "         -0.8655235 ,  0.60430455,  2.2667575 , -0.29738116, -0.4099696 ,\n",
       "         -0.89107805, -0.8062947 , -1.2657534 , -0.08485245, -1.8884033 ,\n",
       "          0.7404237 ,  0.41768047, -2.0189874 , -0.05755699,  2.377851  ],\n",
       "        [-0.27998337, -1.3859123 ,  0.10698268, -1.3735836 , -0.14200824,\n",
       "         -0.17482033, -0.21122655,  0.3158704 ,  0.1185525 ,  0.28879938,\n",
       "          0.9370709 ,  0.04018198, -0.25153676, -0.6329375 , -1.0294958 ,\n",
       "         -0.5823323 ,  2.045318  , -1.3642259 , -1.9342035 , -1.2743288 ,\n",
       "         -0.6586684 , -0.28182498,  0.9323697 , -0.08457363,  0.906175  ,\n",
       "         -0.8600111 , -0.2015023 ,  0.7284611 ,  1.1720419 ,  0.6469196 ,\n",
       "         -0.2801443 , -0.98053426, -0.3272239 , -1.0366045 ,  1.2157944 ,\n",
       "         -0.7499371 , -1.9917974 , -0.86497885, -0.45791706, -1.4926466 ,\n",
       "         -0.89486945,  1.9906793 , -0.7177815 , -0.16504836,  0.82652396,\n",
       "         -1.3220117 , -0.06015726,  0.8756862 , -0.14249341,  1.2598166 ,\n",
       "         -1.704318  , -0.15710427,  0.17737916, -0.56032854, -1.0362716 ,\n",
       "          0.71270883,  0.8934362 , -1.0099937 ,  0.27453166,  1.065665  ,\n",
       "         -1.4030584 , -0.17309335, -0.03669251, -0.22014287,  0.43533298,\n",
       "         -0.91125214, -0.06456779,  1.3187481 , -0.7106892 , -1.1664755 ,\n",
       "          0.13339192, -0.74076056,  0.42453516,  1.3838516 ,  2.025001  ,\n",
       "          1.3470416 , -2.0241137 , -0.14797664,  1.4055749 , -0.12140049,\n",
       "          0.48672053,  0.35313782,  1.1791313 , -0.5302571 , -0.48481798,\n",
       "          0.8369957 ,  0.64878523, -0.59699595, -1.6838257 , -1.499966  ,\n",
       "         -0.25260818,  0.35880968, -0.06970277, -0.3651749 ,  1.8445559 ,\n",
       "          0.81488115, -0.23275727, -0.03421541, -0.78845435, -1.2226037 ]],\n",
       "       dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[ 8.0496025e-01, -5.6310552e-01, -1.8251256e+00,  1.9748609e-01,\n",
       "         -1.0853221e+00, -2.3756485e-02,  5.2735704e-01,  4.7153744e-01,\n",
       "          3.7816456e-01, -7.9956234e-02,  6.0177273e-01, -4.3568191e-01,\n",
       "         -4.4420627e-01,  8.0435020e-01, -7.1204925e-01, -1.7857473e+00,\n",
       "         -4.6723306e-01,  5.1003462e-01,  8.2299036e-01,  4.0035751e-01,\n",
       "         -4.0082273e-01,  7.4531233e-01,  1.5298572e+00,  2.3181047e-01,\n",
       "         -1.1441499e+00,  1.1899252e+00, -3.5299901e-02, -1.6728735e+00,\n",
       "          2.4198054e-01,  1.5679295e+00, -4.1627936e-02,  1.4591883e+00,\n",
       "         -1.3839420e+00,  4.2536482e-01,  6.2104005e-02, -2.0276456e+00,\n",
       "         -5.7433593e-01, -1.0933514e+00, -9.6736616e-01, -4.1543552e-01,\n",
       "          1.5140914e+00,  3.7969398e-01, -1.2437387e-01,  1.8589826e+00,\n",
       "         -1.0384614e-01,  1.3924211e+00, -4.2131960e-01, -3.8596395e-01,\n",
       "          6.9603318e-01,  9.1338468e-01, -2.7406844e-01,  2.4225110e-01,\n",
       "          8.7715685e-01, -5.1218563e-01,  4.9690560e-02,  1.4336969e-01,\n",
       "          1.1471767e+00, -1.3451725e+00, -4.8944544e-02, -3.8639602e-01,\n",
       "          1.1588792e+00, -3.1748455e+00, -3.2867011e-01,  6.4461970e-01,\n",
       "          7.8852884e-03, -1.0189165e+00, -1.0848426e+00, -1.2229537e+00,\n",
       "          8.1600505e-01,  5.8881181e-01,  2.0062634e-01,  5.6563956e-01,\n",
       "          6.7295641e-01,  7.0800602e-01,  6.1954314e-01,  8.1951159e-01,\n",
       "         -9.0277892e-01,  1.5906203e+00, -8.8505751e-01, -1.1271709e-02,\n",
       "          1.4735296e-01, -4.6317139e-01,  7.2821778e-01,  9.0734953e-01,\n",
       "          1.1437012e+00,  9.5885104e-01,  5.2641320e-01,  3.6184350e-01,\n",
       "         -1.2630647e+00,  1.2220840e+00,  1.8495058e-01, -7.9629397e-01,\n",
       "         -1.2617004e+00, -5.8030534e-01, -1.5878802e-03, -8.8962317e-01,\n",
       "         -3.3016968e-01,  3.5816026e-01,  1.5172329e+00, -5.7713586e-01],\n",
       "        [ 1.5581442e-01,  2.7677715e-02, -1.4697038e-01,  1.8957046e+00,\n",
       "          7.5713152e-01,  3.2147300e-01,  6.9967461e-01,  1.2575151e+00,\n",
       "         -1.1167599e+00,  5.0652897e-01, -1.6349288e+00, -8.8815337e-01,\n",
       "          1.2567341e+00, -1.5142537e+00, -7.5254583e-01, -1.5019084e+00,\n",
       "          1.3905147e+00, -1.0810367e+00,  1.4848280e+00, -9.0015519e-01,\n",
       "         -1.4945451e+00, -4.5240802e-01, -1.2903035e-01, -1.6498733e+00,\n",
       "          9.9832475e-01,  3.7155253e-01,  7.2014719e-01, -2.6986286e-01,\n",
       "          9.9912637e-01, -8.0575645e-01, -1.9876988e+00,  1.2400055e+00,\n",
       "          1.0083696e+00, -5.3716630e-01, -1.1068616e+00, -4.1263631e-01,\n",
       "          1.9353727e+00,  1.1781812e+00,  5.5033714e-01, -9.3291634e-01,\n",
       "         -7.5940681e-01, -2.1187076e-01, -3.7676668e-01, -5.8292240e-01,\n",
       "          6.0458410e-01,  7.4289864e-01,  5.7906046e-04,  2.0615914e+00,\n",
       "          2.1029501e+00, -6.1160845e-01, -7.9916710e-01,  1.1560308e+00,\n",
       "         -1.0692427e+00, -1.1852540e+00, -1.6201236e+00,  8.1277961e-01,\n",
       "         -3.2946840e-01, -2.3865694e-01, -4.8854420e-01, -3.8534629e-01,\n",
       "         -2.8639218e-02,  4.3906289e-01, -2.7663082e-01, -6.0335737e-01,\n",
       "         -8.7813383e-01, -1.9971761e+00,  5.3864455e-01,  2.8320923e-01,\n",
       "         -9.7108287e-01,  1.2197548e+00,  4.9955592e-01, -1.1334612e+00,\n",
       "          1.6863761e+00, -8.3050269e-01, -1.5877334e-02, -2.1404762e+00,\n",
       "         -5.0862110e-01,  4.7330394e-01,  1.1747141e+00,  1.8750753e+00,\n",
       "          4.2330191e-01, -1.1589044e+00,  7.7088439e-01, -1.7098087e-01,\n",
       "          6.8786395e-01,  1.2680726e-01,  4.7732386e-01, -1.0093262e+00,\n",
       "          2.3837116e-01,  2.0069094e+00,  9.0876609e-01,  5.1286292e-01,\n",
       "          2.3786469e+00, -3.2698461e-01,  5.5078769e-01, -1.4955211e+00,\n",
       "          2.4504307e-01,  8.4398484e-01, -1.8567036e+00,  1.9036409e+00]],\n",
       "       dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[-4.7075823e-02, -2.5368011e-01, -7.2289091e-01, -1.1695178e-01,\n",
       "         -1.6315579e+00,  8.4177363e-01, -1.0573008e+00,  1.7315568e+00,\n",
       "         -1.5834883e+00, -1.3089235e+00,  1.8375756e-01, -1.3126134e+00,\n",
       "         -1.8355733e+00,  2.4908912e+00, -1.5375757e+00,  1.1092087e+00,\n",
       "          1.9962556e+00,  9.6767861e-01,  3.7402603e-01,  5.2634150e-01,\n",
       "         -1.4881092e+00,  1.2231504e+00, -2.8450301e-01,  4.7677040e-01,\n",
       "          4.6763819e-01, -1.0419150e-01, -2.1134655e+00, -1.2169040e-02,\n",
       "         -7.4953693e-01, -6.4917678e-01,  2.0415109e-01, -1.3313559e+00,\n",
       "          3.3767655e-01,  8.6155427e-01,  1.4461862e+00,  1.2157027e+00,\n",
       "         -6.3142055e-01,  1.4936920e-03, -7.3727560e-01,  9.8617923e-01,\n",
       "         -1.2269776e-01, -2.1174090e+00,  3.6807597e-01,  1.3423846e+00,\n",
       "          2.6136603e+00, -2.7764413e-01,  8.7533534e-01,  2.1399000e+00,\n",
       "         -4.2221504e-01, -3.2712403e-01,  2.0212658e-01, -7.2525680e-02,\n",
       "         -2.9739320e-01,  1.1168485e+00, -8.7151664e-01, -1.2733562e+00,\n",
       "          2.2373490e+00,  1.8494940e+00, -1.1458956e+00,  2.7643311e-01,\n",
       "         -1.2467682e+00,  1.9055592e-01,  1.0658734e+00,  1.3325809e+00,\n",
       "         -1.4458727e+00,  1.3757555e+00,  1.0445859e+00,  5.5070877e-01,\n",
       "          5.6978977e-01, -3.5080805e-01, -1.4016145e-01, -1.9739074e+00,\n",
       "         -1.1141322e+00, -6.1689657e-01, -3.4301043e-01,  2.9930609e-01,\n",
       "         -3.6161077e-01,  9.2984152e-01,  5.3992051e-01, -3.1446487e-01,\n",
       "         -2.9446581e-01, -1.9998612e+00, -1.5629741e+00, -1.3896986e+00,\n",
       "         -2.2289330e-01, -2.5304887e-01, -7.0032495e-01, -7.9322875e-01,\n",
       "         -2.0964402e-01, -1.0336083e+00, -2.3686290e-01,  5.3462857e-01,\n",
       "         -3.5600424e-01, -1.5200665e+00, -4.2338651e-01,  1.3729566e+00,\n",
       "          2.6641691e-01, -6.2172860e-01,  3.1379607e-01, -1.1585507e+00],\n",
       "        [ 8.1736165e-01, -1.4584443e-01, -1.4767427e+00, -4.1270614e-02,\n",
       "          1.5597008e+00,  1.7929153e+00, -7.9658456e-02, -5.7768688e-02,\n",
       "          6.2387848e-01, -8.4990829e-01,  1.7634697e+00,  7.4405098e-01,\n",
       "         -4.7158897e-01, -1.1994852e+00,  9.1439736e-01,  2.6782382e-01,\n",
       "         -5.4055882e-01,  7.5334543e-01,  2.5874751e+00,  3.6122611e-01,\n",
       "         -3.0940753e-01,  8.7903567e-02,  8.9585179e-01,  6.3410139e-01,\n",
       "         -1.3386612e-01, -1.4408368e+00,  1.6587895e-01, -2.8616694e-01,\n",
       "          2.4002539e-01, -1.1040926e+00,  1.3954124e-01, -8.9795893e-01,\n",
       "         -6.5315604e-01,  2.0439517e-01,  1.5504062e+00, -2.8360385e-01,\n",
       "         -9.5295352e-01,  2.4514928e-01,  1.5587428e+00, -1.8799882e-01,\n",
       "          1.0483799e-01,  2.1979017e-02,  1.1497985e+00,  8.3589888e-01,\n",
       "         -1.4173643e-01, -1.5358494e-01,  7.3995781e-01,  8.2843107e-01,\n",
       "         -1.7343824e-03,  9.6719337e-01, -9.0450847e-01, -2.0277674e+00,\n",
       "          8.6771381e-01,  7.0163488e-01, -7.5251776e-01, -4.4615459e-01,\n",
       "          4.2803016e-01,  3.0955073e-01, -3.5934305e-01, -2.0236115e-01,\n",
       "         -1.4412950e-01, -5.5313575e-01,  1.0373850e+00,  2.0475540e+00,\n",
       "          1.0855355e+00, -1.0891484e+00,  2.0926714e+00,  4.4716489e-02,\n",
       "         -5.4966533e-01, -2.7962437e-01,  1.5089366e+00, -1.1699353e+00,\n",
       "         -3.0998904e-01, -3.1089768e-01,  1.7825513e+00,  9.1063344e-01,\n",
       "         -1.0249692e+00,  2.9409969e-01,  3.5626012e-01,  7.2420686e-01,\n",
       "         -8.1303126e-01, -7.3393327e-01, -1.9624278e-01, -1.8503025e+00,\n",
       "         -3.2245848e-01, -3.8292564e-02,  1.5660094e+00,  4.6953484e-01,\n",
       "          7.9165590e-01,  3.4756076e-01,  6.6705620e-01, -5.0980103e-01,\n",
       "          1.8897688e+00, -1.3703591e+00, -2.0524690e+00,  9.6163487e-01,\n",
       "         -2.1156636e-01,  7.4186957e-01, -2.2348995e+00,  2.0134453e-01]],\n",
       "       dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[-2.1465483 ,  0.6409008 ,  1.3366779 ,  1.153524  ,  0.61966366,\n",
       "         -0.4806627 ,  0.60096157, -0.23962644, -0.27641627, -1.107234  ,\n",
       "          0.43209383,  0.05340082,  0.21462086,  0.58534575, -0.839942  ,\n",
       "          0.83526313,  0.35426378,  0.10244299, -0.71870685,  0.9883881 ,\n",
       "         -0.6297039 ,  0.83908486,  0.9720642 , -0.27670857,  0.09678689,\n",
       "         -0.10986459,  0.01777879, -1.622156  , -1.8702496 , -1.3878511 ,\n",
       "          0.40062654,  0.9519499 , -0.98378366, -0.8760048 ,  1.3534545 ,\n",
       "         -1.5422368 , -0.43581018,  0.08953769,  0.21290533,  0.37472817,\n",
       "         -0.70019394,  0.3739284 ,  0.19608787, -1.0761893 ,  0.7566988 ,\n",
       "          0.14604676,  0.98179644, -1.5861213 ,  0.2598568 ,  1.1739986 ,\n",
       "         -0.77699065,  2.0047045 , -0.71010715,  1.0028223 , -1.3395479 ,\n",
       "          0.13728626,  0.4136134 ,  3.1457782 ,  0.13197193, -1.0492038 ,\n",
       "         -0.3359679 , -1.5835277 ,  0.41091228,  0.30815157, -1.4905634 ,\n",
       "          0.28339607, -1.0749292 , -1.336066  ,  0.80696666, -0.5573054 ,\n",
       "         -1.0337193 ,  0.28055233, -1.0535781 , -0.14432365, -0.13862094,\n",
       "          0.6829501 , -1.7157489 , -2.0156136 , -0.71272624,  0.32718706,\n",
       "         -0.44450545,  0.5275974 ,  2.402937  ,  0.52499634,  0.08395869,\n",
       "          1.9775981 , -2.1409373 ,  0.24170244,  2.275694  , -0.7660085 ,\n",
       "         -0.01449952, -1.7639854 ,  0.8629908 ,  0.36893895,  0.2114981 ,\n",
       "         -2.2054124 , -0.29744378,  1.7371738 ,  1.5516756 , -0.15692672],\n",
       "        [ 2.3830965 ,  1.2047694 , -1.9923255 , -0.6837447 , -1.3070462 ,\n",
       "          0.94468904, -0.43739736, -1.2077054 , -0.5328173 , -1.1250796 ,\n",
       "         -0.9892648 ,  1.4572307 , -0.7665373 ,  0.74836093, -0.72245175,\n",
       "          0.4667592 , -0.32875246,  2.3405478 ,  0.47409734, -1.0617812 ,\n",
       "          0.7155263 , -0.6641021 , -1.158055  , -0.19559702, -0.14800183,\n",
       "          1.4730492 ,  0.79465425,  1.108498  , -0.2261366 , -2.5453672 ,\n",
       "          0.76646876, -1.5223006 ,  0.18383856, -0.68030536, -1.9003603 ,\n",
       "          0.68821305, -0.31274307, -0.60464233, -0.46057084,  0.33210275,\n",
       "         -0.6311712 ,  0.76670194,  0.2531803 , -1.6984476 ,  1.108412  ,\n",
       "         -0.61672527,  1.4117676 , -0.7605571 ,  1.0287732 ,  0.17008042,\n",
       "         -2.0154698 ,  0.18164757, -0.3880825 ,  0.71471953, -0.74074394,\n",
       "         -1.4046726 , -0.02934526, -0.6383871 ,  0.09085857, -0.34919804,\n",
       "          0.72789484,  2.099442  , -2.415596  ,  0.44357592,  0.09380072,\n",
       "         -1.006265  ,  1.4380319 , -1.4159282 , -0.7692098 , -0.51089567,\n",
       "         -0.3386326 , -0.24682516,  0.15294981,  0.74087965,  0.10161749,\n",
       "          0.5239175 ,  1.1446803 , -0.8432159 , -1.5205113 , -1.5194962 ,\n",
       "         -0.619278  ,  0.920246  ,  0.46815038,  1.1503102 , -0.12152739,\n",
       "         -0.9175146 ,  1.1805489 ,  1.2058115 ,  0.07089802,  0.20076734,\n",
       "          0.23218723, -0.33199343, -0.79662776,  1.1053606 ,  1.0916039 ,\n",
       "         -0.6736174 , -0.45969948, -1.9997042 ,  1.5812652 ,  0.65789324]],\n",
       "       dtype=float32)>,\n",
       " <tf.Tensor: shape=(2, 100), dtype=float32, numpy=\n",
       " array([[-1.073203  ,  1.3081534 ,  0.7543718 , -0.48136428,  0.3807888 ,\n",
       "          1.5103701 ,  0.1796965 , -0.04389697,  0.07307632, -1.8938619 ,\n",
       "          0.2074153 , -0.55495095,  0.27901366, -1.4723154 , -0.23164375,\n",
       "          0.3500112 ,  0.8504301 , -0.23968886,  0.8337272 ,  0.10023783,\n",
       "          0.683885  , -0.47887358, -0.9841538 ,  0.37687784, -0.993133  ,\n",
       "          1.1692711 ,  1.015078  , -0.28678435, -0.42325002, -1.8755493 ,\n",
       "          1.212598  ,  1.1474329 ,  1.067117  ,  1.3543983 ,  2.238563  ,\n",
       "          1.536473  , -1.2043517 , -0.08704648,  0.41854006, -1.794605  ,\n",
       "          0.7727277 , -1.5398594 , -1.8495306 ,  1.0546831 ,  1.3507397 ,\n",
       "         -0.9703882 , -0.3249193 , -0.46044746,  0.10420125,  0.98359203,\n",
       "         -1.454522  , -1.1032465 ,  0.6936493 , -0.24697042, -1.2342665 ,\n",
       "          0.6290388 ,  0.6503901 , -0.34966704,  1.882555  ,  0.32876801,\n",
       "          0.80436164,  0.33391818, -0.33214232,  0.36353576, -1.2675217 ,\n",
       "         -0.0720823 , -0.13738236, -0.23367122, -0.44793683, -0.34794813,\n",
       "         -1.306563  , -0.00571122, -0.6219298 ,  0.07148208, -0.22568007,\n",
       "          0.11536593, -0.6578504 , -0.18669446, -0.19632976,  1.2165858 ,\n",
       "         -0.4073604 ,  0.6675829 , -0.46859336,  0.07020177,  0.9385812 ,\n",
       "         -1.3377762 ,  0.5240895 ,  0.21060462,  1.1225164 ,  0.25390008,\n",
       "         -0.18082847,  1.3719761 , -0.18772906,  0.02485867,  0.572486  ,\n",
       "          0.46690017,  0.5378686 ,  0.95920694,  0.33151367, -0.54596865],\n",
       "        [-0.571118  ,  0.34490657, -1.4507705 , -0.7195529 , -0.7871293 ,\n",
       "          0.66745615,  1.5419214 , -0.2956453 ,  0.3513079 , -2.3639321 ,\n",
       "          1.4625925 , -0.28103134,  3.1786854 ,  0.07301069,  0.03421533,\n",
       "          0.5687903 , -1.4493512 ,  0.58450013,  0.16785888,  0.6859942 ,\n",
       "         -1.4994861 ,  0.66921705,  0.48626444,  1.4093746 ,  1.15777   ,\n",
       "         -0.96377563,  0.7770356 ,  0.25997162,  0.7057683 , -0.6797086 ,\n",
       "          0.75382876,  0.3077731 ,  0.05712981,  1.4726588 ,  1.1330235 ,\n",
       "         -0.608612  ,  1.6438365 ,  0.26526102,  0.77199537,  0.33726764,\n",
       "          0.9047275 , -0.9256272 , -0.213507  , -2.03864   , -1.2240255 ,\n",
       "          1.0548923 , -0.48943302,  1.4016752 ,  0.8404375 ,  1.2715735 ,\n",
       "         -0.3382408 , -1.3772535 ,  0.12802124,  0.2603198 , -0.99944043,\n",
       "          2.0729492 ,  0.4093066 , -0.21846016,  0.10763012,  0.67004937,\n",
       "         -0.33307922, -1.9674284 , -0.87160915, -0.66134685,  0.70905507,\n",
       "         -1.7594562 ,  0.58156306,  0.41694024, -1.3752617 , -1.5242528 ,\n",
       "          0.04696382,  0.27405298, -0.9468013 ,  1.0057997 ,  0.9652042 ,\n",
       "         -1.525634  , -1.6899654 , -0.7521092 , -0.697585  ,  0.27502567,\n",
       "         -0.12311819, -0.82843024,  1.037741  , -0.79553306,  0.76422256,\n",
       "         -0.74180907,  2.2548552 , -0.80403113, -0.4363241 , -0.13166746,\n",
       "          1.0265237 ,  2.0345237 , -1.068978  ,  1.7486778 , -3.0368502 ,\n",
       "          2.0023596 , -0.66458946, -0.18452466, -1.3962802 ,  1.3828356 ]],\n",
       "       dtype=float32)>]"
      ]
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "tf.unstack(x, axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 64), dtype=float32, numpy=\n",
       "array([[-1.24565825e-01,  1.67628363e-01,  3.32920969e-01,\n",
       "        -2.50051677e-01,  3.61288697e-01,  7.54924119e-02,\n",
       "         2.22174689e-01, -1.56149924e-01,  1.38563663e-01,\n",
       "        -2.44943216e-01, -5.88322282e-02, -5.15719652e-02,\n",
       "         3.18751447e-02,  2.57326871e-01,  4.79907781e-01,\n",
       "        -3.84414345e-02, -1.99952275e-02,  9.92624238e-02,\n",
       "         2.68418472e-02,  3.81919965e-02, -4.57481621e-03,\n",
       "         1.14992216e-01, -4.06227380e-01,  1.09003782e-01,\n",
       "         1.39182553e-01, -4.08028960e-01,  7.34840482e-02,\n",
       "         2.02561274e-01,  6.03734143e-02,  1.39911503e-01,\n",
       "        -2.42544767e-02, -1.20804511e-01,  2.39198089e-01,\n",
       "         1.21275790e-01,  1.10223003e-01, -3.21807563e-01,\n",
       "         8.92268345e-02,  2.90686280e-01, -3.84874284e-01,\n",
       "         1.18716240e-01, -3.13059270e-01,  1.06330708e-01,\n",
       "        -2.60352381e-02, -2.59872265e-02, -8.61537978e-02,\n",
       "        -1.44321799e-01, -3.05877626e-01, -8.22709724e-02,\n",
       "         1.26324743e-01, -1.87721029e-01, -4.21349674e-01,\n",
       "        -2.61107590e-02, -4.18592505e-02,  2.51190305e-01,\n",
       "         9.84656811e-02,  3.63844901e-01, -2.59729356e-01,\n",
       "        -8.70206580e-02,  1.42960846e-01,  2.99836934e-01,\n",
       "         1.92049205e-01, -1.91988563e-03, -1.78686112e-01,\n",
       "         2.62852870e-02],\n",
       "       [ 2.59393360e-02,  2.68175248e-02,  6.74200654e-02,\n",
       "         1.99507594e-01, -5.18906534e-01, -3.11691761e-02,\n",
       "        -2.21289247e-01, -2.01201454e-01,  8.31588265e-03,\n",
       "        -3.89017642e-01,  1.65336028e-01, -1.36203006e-01,\n",
       "         3.32228094e-01, -1.44832591e-02,  7.78664276e-02,\n",
       "        -4.30177808e-01,  1.56364620e-01, -2.06693873e-01,\n",
       "        -1.77856535e-01, -1.04190633e-01,  3.30256909e-01,\n",
       "        -1.03671841e-01, -2.42985353e-01, -1.36995405e-01,\n",
       "        -1.69268897e-04,  4.49232668e-01, -1.39989063e-01,\n",
       "        -1.89692676e-01, -4.87877935e-01, -3.91501218e-01,\n",
       "        -4.18477692e-02,  3.26419502e-01,  2.65701711e-01,\n",
       "         9.20833945e-02, -6.61541969e-02, -2.13565081e-01,\n",
       "         5.69961406e-02,  1.04692385e-01,  1.07737459e-01,\n",
       "        -9.42324921e-02,  2.75686562e-01, -2.09639847e-01,\n",
       "         6.31471979e-04, -3.67995143e-01, -4.69788946e-02,\n",
       "        -1.41567305e-01, -2.29013368e-01, -4.60408032e-01,\n",
       "        -1.89032257e-01, -2.97832698e-01, -2.02952981e-01,\n",
       "         2.83982992e-01, -6.24832883e-02, -2.10182756e-01,\n",
       "        -8.37041158e-03,  2.68276155e-01, -1.00495882e-01,\n",
       "        -2.55662650e-01,  5.47545031e-02,  1.09567344e-01,\n",
       "         5.44134201e-03,  2.81459168e-02,  1.08734548e-01,\n",
       "         3.00109804e-01]], dtype=float32)>"
      ]
     },
     "metadata": {},
     "execution_count": 16
    }
   ],
   "source": [
    "layer = layers.LSTM(64, return_sequences=False)\n",
    "out = layer(x)\n",
    "out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "TensorShape([2, 80, 64])"
      ]
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "source": [
    "net = Sequential([\n",
    "    layers.LSTM(64, return_sequences=True),\n",
    "    layers.LSTM(64)\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 64), dtype=float32, numpy=\n",
       "array([[-0.03109153, -0.05117425, -0.41906828, -0.06709851, -0.693869  ,\n",
       "        -0.3022399 , -0.13941851, -0.48869747, -0.737234  ,  0.2475737 ,\n",
       "        -0.5693398 ,  0.25147876, -0.14365289,  0.5226742 ,  0.29180616,\n",
       "        -0.42737767,  0.6739683 ,  0.19009788,  0.3892646 , -0.24272896,\n",
       "        -0.20687953,  0.03522773,  0.26001236,  0.42136377,  0.42273223,\n",
       "        -0.0274439 ,  0.52482903, -0.40584084, -0.37856013,  0.09116854,\n",
       "         0.3104653 ,  0.03867452,  0.40772048,  0.3216092 ,  0.43277782,\n",
       "         0.4932813 , -0.35285532, -0.34182885, -0.0273606 ,  0.1285156 ,\n",
       "        -0.48414448,  0.12029657,  0.3840594 ,  0.51251304, -0.09697375,\n",
       "        -0.20540735,  0.19806397,  0.4207811 , -0.60573435, -0.6945622 ,\n",
       "        -0.55214965,  0.19826984,  0.03498349,  0.21960041, -0.49959332,\n",
       "        -0.30242196,  0.38299963, -0.6571995 , -0.42050916, -0.49414536,\n",
       "         0.38236463, -0.04906614,  0.23401877, -0.07420552],\n",
       "       [-0.28129375, -0.31724137, -0.45991528, -0.12187439,  0.48266125,\n",
       "         0.37634343, -0.05320521,  0.22736044, -0.58232987,  0.31087166,\n",
       "        -0.5743232 ,  0.739014  ,  0.60072076,  0.15446417,  0.15773985,\n",
       "        -0.13263059, -0.3779121 ,  0.8009477 ,  0.00408776, -0.34304494,\n",
       "         0.5892028 ,  0.86822104, -0.48704925,  0.03626032,  0.69099253,\n",
       "         0.808967  ,  0.38477987, -0.3880525 , -0.06037107,  0.06289496,\n",
       "        -0.31498036,  0.3733507 ,  0.6818614 ,  0.3421862 ,  0.4218256 ,\n",
       "        -0.5310093 , -0.73757845, -0.00260217,  0.1864981 , -0.18899545,\n",
       "         0.35168317, -0.5843717 ,  0.136644  , -0.03439358, -0.09205475,\n",
       "         0.36897895,  0.24136484, -0.14264777, -0.41720057,  0.5407331 ,\n",
       "        -0.02320929,  0.46035278, -0.37241524, -0.39001378,  0.18931806,\n",
       "        -0.21049373,  0.5739202 , -0.0261184 ,  0.35453886,  0.39672443,\n",
       "         0.44436637, -0.14036652, -0.47677636, -0.58406365]],\n",
       "      dtype=float32)>"
      ]
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "h =[tf.zeros([2, 64])]\n",
    "cell = layers.GRUCell(64)\n",
    "\n",
    "for xt in tf.unstack(x, axis=1):\n",
    "    out, h = cell(xt, h)\n",
    "out"
   ]
  }
 ]
}